package org.bao.service;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;


/**
* @ClassName: SmsService
* @Description: 短信服务接入
* @author bql
* @date 2019年4月28日
*
*/
public class SmsService {
    public static void smsexecute(String tel,String stryan) {
        DefaultProfile profile = DefaultProfile.getProfile("default", "LTAIecaBhRfQXg5A", "l1XxiyasaBEyctjkq48xiIEOeVdWpr");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        //request.setProtocol(ProtocolType.HTTPS);
        request.setMethod(MethodType.POST);
        request.setDomain("dysmsapi.aliyuncs.com");
        request.setVersion("2017-05-25");
        request.setAction("SendSms");
        request.putQueryParameter("PhoneNumbers", tel);
        request.putQueryParameter("SignName", "联箱");
        request.putQueryParameter("TemplateCode", "SMS_164269595");
        request.putQueryParameter("TemplateParam", "{\"code\":\""+ stryan +"\"}");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}
